﻿Imports System.Data.SqlClient
Imports System.IO

Partial Class photoalbums_admin_getfiles
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'Dim FileList() As String = Directory.GetFiles("C:\inetpub\wwwroot\NetMedia\img\imgGallery\cockpics")



        'For Each File As String In FileList
        '    Response.Write(Replace(File, "C:\inetpub\wwwroot\NetMedia\img\imgGallery\cockpics\", "") & "<br />")
        'Next



    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim s As New Shell32.Shell
        Dim f As Shell32.Folder = s.NameSpace("C:\Users\George\Pictures\new girls")
        Dim i As Shell32.FolderItem

        Dim sb As New StringBuilder
        Dim sql As String = "INSERT INTO images (albumId, thumb, image, path, hidden) VALUES ('1','', @image, '', False)"

        Dim connString As String = ConfigurationManager.ConnectionStrings("Henson Family").ConnectionString
        Dim conn As New SqlConnection(connString)
        Dim comm As New SqlCommand(sql, conn)
        conn.Open()


        Dim int As Integer = 0
        Dim FileList() As String = Directory.GetFiles("C:\Users\George\Pictures\new girls")
        For Each File As String In FileList
            Dim fileName As String = ""
            Dim xml As String = ""
            Dim imgHeight As String
            Dim imgWidth As String
            'i = f.ParseName()

            fileName = Replace(File, "C:\Users\George\Pictures\new girls\", "")
            i = f.ParseName(fileName)
            Dim imgTitle As String = f.GetDetailsOf(i, 21)


            If String.IsNullOrEmpty(imgTitle) Then
                imgTitle = fileName
            End If

            Dim heightWidth As String = f.GetDetailsOf(i, 31)
            If heightWidth.Contains("x") Then
                Dim heightOrWidth As String() = Split(heightWidth, " x ")
                imgHeight = heightOrWidth(0).Trim()
                imgWidth = heightOrWidth(1).Trim()
            End If





            comm = New SqlCommand("INSERT INTO Images (UserId, Title, Caption, FilePath, Height, Width, [Private]) VALUES ('3', '" & imgTitle & "','', '" & fileName & "', '" & imgHeight & "', '" & imgWidth & "', 'False')", conn)
            lblXml.Text += "INSERT INTO Images (UserId, Title, Caption, FilePath, Height, Width, [Private]) VALUES ('3', '" & imgTitle & "','', '" & fileName & "', '" & imgHeight & "', '" & imgWidth & "','False') <br />"
            'comm.Parameters.AddWithValue("@image", File)
            'comm.ExecuteNonQuery()
            'comm.Parameters.Clear()

            'sb.Append("<slide title=""" & TextBox1.Text & """ description=""" & TextBox2.Text & """ source=""/sausage/images/" & fileName & """ thumbnail=""/sausage/images/" & fileName & """ />")
            'sb.AppendLine()

            'Directory.Move("C:\inetpub\wwwroot\blog\sausage\addimages\new", "C:\inetpub\wwwroot\blog\sausage\images")
            int += 1
        Next
        'lblXml.Text = sb.ToString()
        conn.Close()
    End Sub
End Class
